package com.itheima.controller;


import com.itheima.constant.MessageConstant;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.CheckGroup;
import com.itheima.service.CheckGroupService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/checkGroup")
public class CheckGroupController {

    @Reference
    private CheckGroupService checkGroupService;

    /**
     * 分页或者查询
     */
    @GetMapping("/findPage")
    public Result findPage(QueryPageBean queryPageBean){

        return checkGroupService.queryPage(queryPageBean);

    }
    /**
     * 添加
     */
    @PostMapping("/save")
    public Result save(@RequestBody CheckGroup checkGroup,Integer[] checkitemIds){

        return checkGroupService.add(checkGroup, checkitemIds);

    }

    /**
     * 编辑
     */
    @PostMapping("/update")
    public Result update(@RequestBody CheckGroup checkGroup,Integer[] checkitemIds){

        return checkGroupService.update(checkGroup, checkitemIds);

    }

    /**
     * 根据检查组id 查询 检查组
     */
    @GetMapping("/findCheckGroup/{id}")
    public Result findCheckGroup(@PathVariable Integer id){

        return checkGroupService.queryById(id);

    }

    /**
     * 根据检查组id 删除
     */
    @GetMapping("/delete/{id}")
    public Result delete(@PathVariable Integer id){

        return  checkGroupService.delete(id);

    }

    /**
     * 查询全部
     * @return
     */
    @GetMapping("/queryAll")
    public Result queryAll(){

        return checkGroupService.queryAll();

    }














}
